import Queue from "./Queue";

export default class ArrayQueue<T> implements Queue<T> {
  protected datas: T[] = [];

  enqueue(element: T): void {
    this.datas.push(element);
  }
  dequeue(): T | undefined {
    return this.datas.shift();
  }
  front(): T | undefined {
    return this.datas[0];
  }
  isEmpty(): boolean {
    return this.size === 0;
  }
  get size(): number {
    return this.datas.length;
  }
  toString(): string {
    return this.datas.reduce((pre, cur) => (pre += cur + " "), "");
  }
}
